package com.bawei.rk_01.Adapter

import android.content.Context
import android.view.RoundedCorner
import android.widget.ImageView
import com.bawei.rk_01.R
import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.load.resource.bitmap.CenterCrop
import com.bumptech.glide.load.resource.bitmap.RoundedCorners

class GlideUtils {

    companion object{

        fun loadImage(context: Context,url:String,imageView: ImageView){
            Glide.with(context)
                .load(url)
                .error(R.drawable.ic_launcher_background)
                .placeholder(R.drawable.ic_launcher_background)
                .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
                .skipMemoryCache(false)
                .into(imageView)
        }

        fun loadcircleImage(context: Context,url: String,imageView: ImageView){
            Glide.with(context).load(url)
                .error(R.drawable.ic_launcher_background)
                .placeholder(R.drawable.ic_launcher_background)
                .circleCrop()
                .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
                .skipMemoryCache(false)
                .into(imageView)
        }

        fun loadcollectionImage(context: Context,url: String,imageView: ImageView,radius:Int){
            Glide.with(context).load(url)
                .error(R.drawable.ic_launcher_background)
                .placeholder(R.drawable.ic_launcher_background)
                .transform(CenterCrop(),RoundedCorners(radius))
                .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
                .skipMemoryCache(false)
                .into(imageView)
        }

    }

}